import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import (DeclareLaunchArgument, GroupAction,
                            IncludeLaunchDescription, SetEnvironmentVariable)
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node
from launch_ros.actions import PushRosNamespace

def generate_launch_description():

    ld = LaunchDescription()
    # 启动硬件驱动launch
    hardware_controller_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([os.path.join(  
         get_package_share_directory('hardware_controller'), 'launch'),  
         '/hardware_controller.launch.py'])
    )
    # 启动激光雷达launch
    lslidar_driver_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([os.path.join(  
        #  get_package_share_directory('lslidar_driver'), 'launch'),  
        #  '/lslidar_launch.py'])
        get_package_share_directory('sllidar_ros2'), 'launch'),  
         '/sllidar_a1_launch.py'])
    )

    # 启动Imu
    wit_imu_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([os.path.join(  
         get_package_share_directory('wit_imu_ros2'), 'launch'),  
         '/wit_imu.launch.py'])
    )

    # 启动深度相机launch
    # ros2 run orbbec_camera list_devices_node
    orbbec_camera_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([os.path.join(  
         get_package_share_directory('orbbec_camera'), 'launch'),  
         '/dabai_dcw.launch.py'])
    )
    
    return LaunchDescription(
        [
            hardware_controller_launch,
            wit_imu_launch,
            lslidar_driver_launch,
            orbbec_camera_launch,
        ]
    )